<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Report extends Backend {

	public function __construct()
	{
		parent::__construct();
		$this->load->model(['adword/adaccount_model','adword/adaccountreport_model','adword/adproducts_model']);
		$this->data['page_home']  = lang('lang_dashboard');
		$this->data['page_title'] = "谷歌广告产品报表";
        $this->data['curreny'] = ["USD"=>"$","CNY"=>"¥"];
	}

    public function index()
    {

		$key=trim($this->input->get('keyword'));
		$accountid=trim($this->input->get('accountid'));
        $timelimit=$this->input->get("timelimit");

		if(!$timelimit)
		{
			$timelimit=[
				"start"=>date("Y-m-d",strtotime("-1 days")),
				"end"=>date("Y-m-d",strtotime("-1 days")),
			];
        }

        $accountmap = $this->adaccount_model->getaccountmap();
        $result = $this->adproducts_model->getrangelist($timelimit,$accountid,$key);
        $this->data["result"]=$result;
        $this->data["map"]=$accountmap;


		$keyword = array(
			'name'      => 'keyword',
			'id'        => 'keyword',
			'value'     =>  $key,
			'class'     =>  'form-control input-sm',
			'placeholder'=> '请输入关键字',
			'maxlength' => '100'
		);
		$this->data['keyword']=$keyword;
		$this->data['sacid']=$accountid;
        $this->data["timerange"]=$timelimit;
        $this->data['content_header_title'] = content_header_title($this->data['page_title']);
		$this->data['content'] = 'adword/product';

		$this->render();
	}
	
}

